<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<title>Bloomberg Development Environment</title>
<html>
<pre>
// Copyright 2016-2023 Bloomberg Finance L.P.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// bmqt_propertytype.h                                                -*-C++-*-
#ifndef INCLUDED_BMQT_PROPERTYTYPE
#define INCLUDED_BMQT_PROPERTYTYPE

//@PURPOSE: Provide enum for the supported data types for a message property.
//
//@CLASSES:
//  bmqt::PropertyType: Enum for supported data types for a message property.
//
//@DESCRIPTION: This component contains &#39;bmqt::PropertyType&#39; which describes
// various data types that are supported for message properties.
//
///Data Types and Size
///-------------------
// This section describes the size of each data type:
//..
//
//  +----------------------------------------------------+
//  | Data Type                      | Size (in bytes)   |
//  +====================================================+
//  | BOOL                           | 1
//  | CHAR                           | 1                 |
//  +----------------------------------------------------+
//  | SHORT                          | 2                 |
//  +----------------------------------------------------+
//  | INT                            | 4                 |
//  +----------------------------------------------------+
//  | INT64                          | 8                 |
//  +----------------------------------------------------+
//  | STRING                         | variable          |
//  +----------------------------------------------------+
//  | BINARY                         | variable          |
//  +----------------------------------------------------+
//..
//
// Note that the difference between &#39;BINARY&#39; and &#39;STRING&#39; data types is that
// the former allows null (&#39;\0&#39;) character while the later does not.


// BMQ
#include &lt;bmqscm_version.h&gt;

// BDE
#include &lt;bsl_iosfwd.h&gt;
#include &lt;bsl_string.h&gt;

namespace BloombergLP {
namespace bmqt {

                            // ===================
                            // struct PropertyType
                            // ===================

struct PropertyType {
    // This enum represents the supported data types for a message property.

    // TYPES
    enum Enum {
        e_UNDEFINED = 0
      , e_BOOL      = 1
      , e_CHAR      = 2
      , e_SHORT     = 3
      , e_INT32     = 4
      , e_INT64     = 5
      , e_STRING    = 6
      , e_BINARY    = 7
    };

    // CONSTANTS
    static const int k_LOWEST_SUPPORTED_PROPERTY_TYPE = e_BOOL;
        // NOTE: This value must always be equal to the lowest type in the
        // enum because it is being used as a lower bound to verify that a
        // Property&#39;s &#39;type&#39; field is a supported type.

    static const int k_HIGHEST_SUPPORTED_PROPERTY_TYPE = e_BINARY;
        // NOTE: This value must always be equal to the highest type in the
        // enum because it is being used as an upper bound to verify a
        // Property&#39;s &#39;type&#39; field is a supported type.

    // CLASS METHODS
    static bsl::ostream&amp; print(bsl::ostream&amp;      stream,
                               PropertyType::Enum value,
                               int                level = 0,
                               int                spacesPerLevel = 4);
        // Write the string representation of the specified enumeration &#39;value&#39;
        // to the specified output &#39;stream&#39;, and return a reference to
        // &#39;stream&#39;.  Optionally specify an initial indentation &#39;level&#39;, whose
        // absolute value is incremented recursively for nested objects.  If
        // &#39;level&#39; is specified, optionally specify &#39;spacesPerLevel&#39;, whose
        // absolute value indicates the number of spaces per indentation level
        // for this and all of its nested objects.  If &#39;level&#39; is negative,
        // suppress indentation of the first line.  If &#39;spacesPerLevel&#39; is
        // negative, format the entire output on one line, suppressing all but
        // the initial indentation (as governed by &#39;level&#39;).  See &#39;toAscii&#39; for
        // what constitutes the string representation of a
        // &#39;PropertyType::Enum&#39; value.

    static const char *toAscii(PropertyType::Enum value);
        // Return the non-modifiable string representation corresponding to the
        // specified enumeration &#39;value&#39;, if it exists, and a unique (error)
        // string otherwise.  The string representation of &#39;value&#39; matches its
        // corresponding enumerator name with the &#39;e_&#39; prefix elided.  Note
        // that specifying a &#39;value&#39; that does not match any of the enumerators
        // will result in a string representation that is distinct from any of
        // those corresponding to the enumerators, but is otherwise
        // unspecified.

    static bool fromAscii(PropertyType::Enum       *out,
                          const bslstl::StringRef&amp;  str);
        // Return true and fills the specified &#39;out&#39; with the enum value
        // corresponding to the specified &#39;str&#39;, if valid, or return false and
        // leave &#39;out&#39; untouched if &#39;str&#39; doesn&#39;t correspond to any value of
        // the enum.
};

// FREE OPERATORS
bsl::ostream&amp; operator&lt;&lt;(bsl::ostream&amp;      stream,
                         PropertyType::Enum value);
    // Format the specified &#39;value&#39; to the specified output &#39;stream&#39; and return
    // a reference to the modifiable &#39;stream&#39;.

}  // close package namespace


// ============================================================================
//                             INLINE DEFINITIONS
// ============================================================================

                            // -------------------
                            // struct PropertyType
                            // -------------------

inline
bsl::ostream&amp;
bmqt::operator&lt;&lt;(bsl::ostream&amp;            stream,
                 bmqt::PropertyType::Enum value)
{
    return bmqt::PropertyType::print(stream, value, 0 , -1);
}

}  // close enterprise namespace

#endif
</pre>
</body>
</html>
